"use strict";
cc._RF.push(module, '23bdaIjIcVOgarfbAw0HSdF', 'HeroInfoViewUI');
// scripts/HeroInfoViewUI.js

"use strict";

var e = require;
var t = module;
var o = exports;

var _ii,
    nn = void 0 && (void 0).__extends || (_ii = function ii(t, e) {
  return (_ii = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _ii(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    rr = void 0 && (void 0).__awaiter || function (t, e, o, i) {
  return new (o || (o = Promise))(function (n, a) {
    function r(t) {
      try {
        l(i.next(t));
      } catch (e) {
        a(e);
      }
    }

    function s(t) {
      try {
        l(i["throw"](t));
      } catch (e) {
        a(e);
      }
    }

    function l(t) {
      var e;
      t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
        t(e);
      })).then(r, s);
    }

    l((i = i.apply(t, e || [])).next());
  });
};

var oo = void 0 && (void 0).__decorate || function (e, t, a, n) {
  var i,
      o = arguments.length,
      s = o < 3 ? t : null === n ? n = Object.getOwnPropertyDescriptor(t, a) : n;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);else for (var r = e.length - 1; r >= 0; r--) {
    (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
  }
  return o > 3 && s && Object.defineProperty(t, a, s), s;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var a = e("NotifyEventType"),
    n = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("ModuleUI"),
    l = e("Game"),
    _ = e("RoleSoldierInfo"),
    c = e("AD"),
    d = e("Toast"),
    h = e("ActivityViewUI"),
    u = e("GetZsViewUI"),
    p = cc._decorator,
    m = p.ccclass,
    f = p.property,
    v = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    return t.hero_ske = null, t.hero_name = null, t.skill_btn_node = [], t.get_term = null, t.buy_btn_node = null, t.show_btn_node = null, t.choose_hero_index = 0, t;
  }

  return nn(t, e), t.prototype.initView = function () {
    e.prototype.initView.call(this);
  }, t.prototype.OnClick = function (t) {
    var o = this;
    e.prototype.OnClick.call(this, t);
    var i = t.node.name,
        s = n.GlobalParams.playerSkinInfo.value;

    switch (i) {
      case "back_btn":
        this.closeThisPopup();
        break;

      case "skill_btn_1":
        this.clickSkillInfo(0);
        break;

      case "skill_btn_2":
        this.clickSkillInfo(1);
        break;

      case "skill_btn_3":
        this.clickSkillInfo(2);
        break;

      case "buy_btn":
        var _ = l["default"].shop_role_info[this.choose_hero_index],
            p = n.GlobalParams.PlayerInfo.value;
        _.type < 2 ? (0 == _.type ? p.coin < _.num ? d["default"].showNewToast("金币不足") : (this.uiManager.addCoinNum(-1 * _.num), s.have_hero.push(this.choose_hero_index), s.use[0] = this.choose_hero_index) : p.zs < _.num ? this.uiManager.showPopup("GetZsViewUI", function (e) {
          e.getComponent(u["default"]).showPopupInfoView(0);
        }) : (this.uiManager.addZsNum(-1 * _.num), s.have_hero.push(this.choose_hero_index), s.use[0] = this.choose_hero_index), n.GlobalParams.PlayerInfo.value = p, n.GlobalParams.playerSkinInfo.value = s, this.emitEvent(a["default"].SEND_UPDATE_MY_USE_HORE_INFO), this.showRoleSkeBtn()) : 2 == _.type ? this.uiManager.showPopup("ActivityViewUI", function (e) {
          e.getComponent(h["default"]).showActivityView(1);
        }) : 3 == _.type ? this.uiManager.showPopup("ActivityViewUI", function (e) {
          e.getComponent(h["default"]).showActivityView(0);
        }) : 4 == _.type ? c["default"].getInstance().showVideo(function (e) {
          r["default"].playGameBGM(), e == c.ResultEnum.Success && (s.have_hero.push(o.choose_hero_index), s.use[0] = o.choose_hero_index, n.GlobalParams.PlayerInfo.value = p, n.GlobalParams.playerSkinInfo.value = s, o.emitEvent(a["default"].SEND_UPDATE_MY_USE_HORE_INFO), o.showRoleSkeBtn());
        }) : 5 == _.type && this.uiManager.showPopup("StoreHouseViewUI");
        break;

      case "show_btn":
        s.use[0] = this.choose_hero_index, n.GlobalParams.playerSkinInfo.value = s, this.emitEvent(a["default"].SEND_UPDATE_MY_USE_HORE_INFO), this.showRoleSkeBtn();
    }
  }, t.prototype.showHeroInfo = function (e) {
    var t = this;
    this.choose_hero_index = e;
    var o = l["default"].shop_role_info[e].id;
    this.uiManager.getRoleSkele(o, function (e) {
      t.hero_ske.skeletonData = e, t.hero_ske.setAnimation(0, "attack_skill_1", !0);
    });
    var a = _["default"].Role_info[o],
        n = _["default"].Hore_Skill_Info[o];
    this.hero_name.spriteFrame = i["default"].getInstance().getHeroHeadFrame("hero_name_" + a.id);
    var r = this.skill_btn_node[0].children[2];
    r.children[0].children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getHeroSkilIcon(o + "a"), r.children[0].children[1].getComponent(cc.Label).string = "" + n.one_name, r.children[0].children[2].getComponent(cc.Label).string = "" + a.S1_des, r.children[1].getComponent(cc.Label).string = "" + n.one_info, r.children[2].children[0].getComponent(cc.Label).string = n.one_time + "秒";
    var s = this.skill_btn_node[1].children[2];
    s.children[0].children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getHeroSkilIcon(o + "b"), s.children[0].children[1].getComponent(cc.Label).string = "" + n.two_name, s.children[0].children[2].getComponent(cc.Label).string = "" + a.S2_des, s.children[1].getComponent(cc.Label).string = "" + n.two_info, s.children[2].children[0].getComponent(cc.Label).string = n.two_time + "秒";
    var c = this.skill_btn_node[2].children[2];
    c.children[0].children[0].getComponent(cc.Sprite).spriteFrame = i["default"].getInstance().getHeroSkilIcon(o + "c"), c.children[0].children[1].getComponent(cc.Label).string = "" + n.three_name, c.children[0].children[2].getComponent(cc.Label).string = "" + a.S3_des, c.children[1].getComponent(cc.Label).string = "" + n.three_info, c.children[2].children[0].getComponent(cc.Label).string = n.three_time + "秒", this.showRoleSkeBtn(), this.clickSkillInfo(0);
  }, t.prototype.clickSkillInfo = function (e) {
    for (var t = 0; t < this.skill_btn_node.length; t++) {
      var o = this.skill_btn_node[t];
      o.children[0].active = t == e, o.children[2].active = t == e, t == e && (o.children[2].scale = 0, this.hero_ske.setAnimation(0, "attack_skill_" + (t + 1), !0), cc.tween(o.children[2]).to(0.3, {
        scaleX: -1,
        scaleY: 1
      }).start());
    }
  }, t.prototype.showRoleSkeBtn = function () {
    var e = this.choose_hero_index,
        t = n.GlobalParams.playerSkinInfo.value,
        o = l["default"].shop_role_info[e];
    this.show_btn_node.parent.active = -1 != t.have_hero.indexOf(e), this.show_btn_node.getComponent(cc.Button).interactable = t.use[0] != e, this.show_btn_node.children[0].active = t.use[0] != e, this.show_btn_node.children[1].active = t.use[0] == e, this.buy_btn_node.parent.active = -1 == t.have_hero.indexOf(e), this.get_term.active = -1 == t.have_hero.indexOf(e);

    for (var a = 0; a < this.get_term.childrenCount; a++) {
      this.get_term.children[a].active = a == o.type, a < 2 && o.type < 2 && (this.get_term.children[a].children[1].getComponent(cc.Label).string = "x " + o.num);
    }

    this.buy_btn_node.active && (this.buy_btn_node.children[0].active = -1 != [0, 1].indexOf(o.type), this.buy_btn_node.children[1].active = -1 != [2, 3, 4, 5].indexOf(o.type), this.buy_btn_node.children[1].children[1].active = 4 == o.type);
  }, oo([f(sp.Skeleton)], t.prototype, "hero_ske", void 0), oo([f(cc.Sprite)], t.prototype, "hero_name", void 0), oo([f(cc.Node)], t.prototype, "skill_btn_node", void 0), oo([f(cc.Node)], t.prototype, "get_term", void 0), oo([f(cc.Node)], t.prototype, "buy_btn_node", void 0), oo([f(cc.Node)], t.prototype, "show_btn_node", void 0), oo([m], t);
}(s["default"]);

o["default"] = v;

cc._RF.pop();